package com.ruoyi.wms.service.impl;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import com.ruoyi.wms.domain.WmsGoods;
import com.ruoyi.wms.mapper.WmsGoodsMapper;
import com.ruoyi.wms.service.IWmsGoodsService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 商品Service业务层处理
 *
 * @author ruoyi
 * @date 2022-04-15
 */
@Service
public class WmsGoodsServiceImpl implements IWmsGoodsService {
  @Autowired private WmsGoodsMapper wmsGoodsMapper;

  /**
   * 查询商品
   *
   * @param id 商品主键
   * @return 商品
   */
  @Override
  public WmsGoods selectWmsGoodsById(Long id) {
    return wmsGoodsMapper.selectWmsGoodsById(id);
  }

  /**
   * 查询商品列表
   *
   * @param wmsGoods 商品
   * @return 商品
   */
  @Override
  @DataScope(userAlias = "c", deptAlias = "u")
  public List<WmsGoods> selectWmsGoodsList(WmsGoods wmsGoods) {
    return wmsGoodsMapper.selectWmsGoodsList(wmsGoods);
  }

  /**
   * 新增商品
   *
   * @param wmsGoods 商品
   * @return 结果
   */
  @Override
  public int insertWmsGoods(WmsGoods wmsGoods) {
    wmsGoods.setCreateTime(DateUtils.getNowDate());
    return wmsGoodsMapper.insertWmsGoods(wmsGoods);
  }

  /**
   * 修改商品
   *
   * @param wmsGoods 商品
   * @return 结果
   */
  @Override
  public int updateWmsGoods(WmsGoods wmsGoods) {
    wmsGoods.setUpdateTime(DateUtils.getNowDate());
    return wmsGoodsMapper.updateWmsGoods(wmsGoods);
  }

  /**
   * 批量删除商品
   *
   * @param ids 需要删除的商品主键
   * @return 结果
   */
  @Override
  public int deleteWmsGoodsByIds(Long[] ids) {
    return wmsGoodsMapper.deleteWmsGoodsByIds(ids);
  }

  /**
   * 删除商品信息
   *
   * @param id 商品主键
   * @return 结果
   */
  @Override
  public int deleteWmsGoodsById(Long id) {
    return wmsGoodsMapper.deleteWmsGoodsById(id);
  }
}
